package cn.ekuma.epos.analysis.front.product;

import java.util.Date;

import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

import com.openbravo.bean.Product;
import com.openbravo.bean.erp.viewbean.FrontProductAnalysisInfo;
import com.openbravo.bean.viewbean.ProductStoreView;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.gui.MessageInf;

import com.openbravo.pos.panels.QuickTimerFilter;
import com.openbravo.pos.panels.event.SellProductChangedListener;
import com.openbravo.pos.panels.event.TimeCycleChangedEvent;
import com.openbravo.pos.panels.event.TimeCycleChangedListener;
import com.openbravo.pos.panels.link.AbstractProductLinkTablePanel;
import com.openbravo.pos.panels.link.model.ProductStoreVTableModel;

import cn.ekuma.epos.analysis.front.product.model.ProductPosSellAnalysisTableModel;
import cn.ekuma.epos.datalogic.I_DataLogicERP;
import cn.ekuma.epos.datalogic.I_DataLogicSales;

public class JSimialProductPosSellPanel extends AbstractProductLinkTablePanel<FrontProductAnalysisInfo> implements TimeCycleChangedListener,SellProductChangedListener{
	 
        String locatin;
        String product;
	    public JSimialProductPosSellPanel(I_DataLogicERP dlSales) {
	       super(dlSales,new ProductPosSellAnalysisTableModel());
	    }

	    @Override
		public void baseBeanChanged(Product o) {
		}

	    
	    QuickTimerFilter timeFilter;
		@Override
		public JPanel getToolBar() {
			 timeFilter=new QuickTimerFilter();
			 timeFilter.addTimeCycleChangedListener(this);
			 return timeFilter;
		}

		@Override
		public void timeCycleChanged(TimeCycleChangedEvent e) {
			if(product!=null)
			   baseBeanChanged(locatin,product,e.getStartDate(),e.getEndDate());
		}

		@Override
		public void baseBeanChanged(String locatin, String product, Date startTime, Date endTime) {
		    this.locatin=locatin;
		    this.product=product;
		    try {
	               tableModel.resert(((I_DataLogicERP)dlSales).listFrontProductAnalysisByProductSimilarCode(locatin,product,startTime,endTime));
	        } catch (BasicException ex) {
	            tableModel.resert(null);
	            new MessageInf(ex).show(this);
	        }
			
		}
	    
	    
	}

